package com.metagurukul.metaspace.controller;

import javax.servlet.http.HttpServletRequest;

import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionMessage;
public class PersonalDetailsForm extends ActionForm {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private String userName;
	private String name;
	private String contact;
	private String gender;
	private String date;
	/**
	 * @return the userName
	 */
	public String getUserName() {
		return userName;
	}
	/**
	 * @param userName the userName to set
	 */
	public void setUserName(String userName) {
		this.userName = userName;
	}

	/**
	 * @return the contact
	 */
	public String getContact() {
		return contact;
	}
	/**
	 * @param name the name to set
	 */
	public void setName(String name) {
		this.name = name;
	}
	/**
	 * @return the name
	 */
	public String getName() {
		return name;
	}
	/**
	 * @param contact the contact to set
	 */
	public void setContact(String contact) {
		this.contact = contact;
	}
	/**
	 * @return the gender
	 */
	public String getGender() {
		return gender;
	}
	/**
	 * @param gender the gender to set
	 */
	public void setGender(String gender) {
		this.gender = gender;
	}
	/**
	 * @return the date
	 */
	public String getDate() {
		return date;
	}
	/**
	 * @param date the date to set
	 */
	public void setDate(String date) {
		this.date = date;
	}
	
	@Override
	public ActionErrors validate(ActionMapping mapping,
			HttpServletRequest request) {
		ActionErrors errors = new ActionErrors();
		if (userName == null || userName.length()<1 ) {
			errors.add("userName", new ActionMessage("error.userName.required"));
		}
		if (name == null || name.length()<1 ) {
			errors.add("name", new ActionMessage("error.name.required"));
		}
		if (contact == null || contact.length() < 10  ) {
			errors.add("contact", new ActionMessage("error.contact.required") );
		}
		if (gender == null || gender.length()<1 ) {
			errors.add("gender", new ActionMessage("error.gender.required") );
		}
		if (date == null)  {
			errors.add("date", new ActionMessage("error.date.required") );
		}
		return errors;
	}
}
